package com.ruoyi.article.service.impl;

import java.util.List;

import com.ruoyi.article.domain.vo.ArticleVO;
import com.ruoyi.category.domain.ArticleCategory;
import com.ruoyi.category.service.IArticleCategoryService;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.article.mapper.ArticleMapper;
import com.ruoyi.article.domain.Article;
import com.ruoyi.article.service.IArticleService;

/**
 * 文章管理Service业务层处理
 *
 * @author ruoyi
 * @date 2025-05-22
 */
@Service
public class ArticleServiceImpl implements IArticleService
{
    @Autowired
    private ArticleMapper articleMapper;
    @Autowired
    private IArticleCategoryService articleCategoryService;

    /**
     * 查询文章管理
     *
     * @param articleId 文章管理主键
     * @return 文章管理
     */
    @Override
    public Article selectArticleByArticleId(Long articleId)
    {
        return articleMapper.selectArticleByArticleId(articleId);
    }

    @Override
    public ArticleVO selectArticleVoByArticleId(Long articleId) {
        return articleMapper.selectArticleVoByArticleId(articleId);
    }

    /**
     * 查询文章管理列表
     *
     * @param article 文章管理
     * @return 文章管理
     */
    @Override
    public List<Article> selectArticleList(Article article)
    {
        return articleMapper.selectArticleList(article);
    }

    @Override
    public List<ArticleVO> selectArticeVO(Article article)
    {
        return articleMapper.selectArticeVO( article);
    }

    @Override
    public List<ArticleVO> selectByUseridArticleVO(Article  article) {
        return articleMapper.selectByUseridArticleVO(article);
    }

    @Override
    public List<ArticleVO> selectArticleByCategoryId(Long categoryId) {
        return articleMapper.selectArticleByCategoryId(categoryId);
    }

    /**
     * 新增文章管理
     *
     * @param article 文章管理
     * @return 结果
     */
    @Override
    public int insertArticle(Article article)
    {
        article.setCreateTime(DateUtils.getNowDate());
        return articleMapper.insertArticle(article);
    }

    /**
     * 修改文章管理
     *
     * @param article 文章管理
     * @return 结果
     */
    @Override
    public int updateArticle(Article article)
    {
        article.setUpdateTime(DateUtils.getNowDate());
        return articleMapper.updateArticle(article);
    }

    /**
     * 批量删除文章管理
     *
     * @param articleIds 需要删除的文章管理主键
     * @return 结果
     */
    @Override
    public int deleteArticleByArticleIds(Long[] articleIds)
    {
        return articleMapper.deleteArticleByArticleIds(articleIds);
    }

    /**
     * 删除文章管理信息
     *
     * @param articleId 文章管理主键
     * @return 结果
     */
    @Override
    public int deleteArticleByArticleId(Long articleId)
    {
        return articleMapper.deleteArticleByArticleId(articleId);
    }
}
